package com.ctg.platform.core.security.web;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.Authentication;
import org.springframework.security.AuthenticationException;
import org.springframework.security.providers.encoding.Md5PasswordEncoder;
import org.springframework.security.providers.encoding.PasswordEncoder;
import org.springframework.security.ui.webapp.AuthenticationProcessingFilter;

public class BizAuthenticationProcessingFilter extends
	AuthenticationProcessingFilter {
	@Override
	protected void onSuccessfulAuthentication(HttpServletRequest request,
		HttpServletResponse response,
		Authentication authResult) throws IOException {    
		System.out.println(request.getParameter("j_username") + "成功的逻辑");
		
	}
	@Override
	protected void onPreAuthentication(HttpServletRequest request,
		HttpServletResponse response) 
		throws IOException {
	PasswordEncoder pe = new Md5PasswordEncoder();
	System.out.println(pe.encodePassword("admin", null));
	System.out.println(request.getParameter("j_username") + "认证之前的逻辑");
	}
	
	protected void onUnsuccessfulAuthentication(HttpServletRequest request,
		HttpServletResponse response,
	    AuthenticationException failed) throws IOException {
	System.out.println(request.getParameter("j_username") + "失败的逻辑");
	}
}
